<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/default-template/templates/editionViewTemplate.xhtml">

	<ui:param name="viewController" value="#{rolController}" />
	
	<ui:define name="currentViewTitle" > Roles </ui:define>					

	<ui:define name="currentViewMenu">
		<ui:include src="../rol/menu.xhtml" />
	</ui:define>
	
	<ui:define name="currentViewDefaultContent" >  
	
		<h:panelGrid width="100%" columns="2" >
		
			<h:panelGrid width="100%" columns="2" >
			
				<p:outputLabel value="Code" for="code" />
				<h:panelGroup>
					<p:inputText id="code" value="#{wrapped.CRol}" required="true" disabled="#{viewHelper.editionModeIsModification}"  />
					<p:message  for="code" />
				</h:panelGroup>
						
				<p:outputLabel value="Libelle" for="libelle" />
				<h:panelGroup>
					<p:inputText id="libelle" value="#{wrapped.LRol}" required="true" style="width:80%" />
					<p:message  for="libelle" />
				</h:panelGroup>
																
			</h:panelGrid>
	
			<h:panelGrid width="100%" columns="2" >
				
				<p:outputLabel value="Assignataire" for="assignataire" />
				<h:panelGroup>
					<p:inputText id="assignataire" value="#{wrapped.tblAsg.CAsg}" required="true" />
					<p:commandButton value="..." action="#{viewController.select('asgController','asg','editRol')}" immediate="true" oncomplete="dialogBasicSelectionWV.show()" update="dialogBasicSelection"  />
					<p:message  for="assignataire" />
				</h:panelGroup>
						
				<p:outputLabel value="Gao" for="gao" />
				<h:panelGroup>
					<p:inputText id="gao" value="#{wrapped.tblAsg.LAsg}" required="false" />
					<p:commandButton value="..." action="#{viewController.select('gaoController','gao','editRol')}" immediate="true" oncomplete="dialogBasicSelectionWV.show()" update="dialogBasicSelection"  />
					<p:message  for="gao" />
				</h:panelGroup>						
																		
			</h:panelGrid>
						
		</h:panelGrid>
		
		
		<p:dialog id="dialogBasicSelection" header="Selection" widgetVar="dialogBasicSelectionWV" width="600"  >  
						
			<h:panelGrid id="panelSelectionCriteria" columns="5"  >
			
	       		<h:outputLabel value="Code" />
	       		<h:inputText   value="#{viewController.selectionController.viewHelper.selectionCriteria.label}" readonly="false" />
	
	       		<h:outputLabel value="Libelle" />
	       		<h:inputText   value="#{viewController.selectionController.viewHelper.selectionCriteria.label}" readonly="true"  />
				
				<p:splitButton 	value="Rechercher" 			actionListener="#{viewController.selectionController.searchForSelection}"	process="panelSelectionCriteria"	update="dataTableSelection"		icon="ui-icon-search"  >
					<p:menuitem value="Recherche avancee" 	action="#{viewController.selectionController.navigateToSelectionView}" 		immediate="true"	icon="ui-icon-search" />
				</p:splitButton>
			
			</h:panelGrid>
			
			<p:separator />
			
	    	<p:dataTable id="dataTableSelection" widgetVar="dataTableSelectionWV" var="data" value="#{viewController.selectionController.viewHelper.selectionDataManager.data}" rowKey="#{data.id}"    
	    		   paginator="true" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  paginatorPosition="top"
	               rows="20" rowsPerPageTemplate="20,40,60,80,100" 
	               sortMode="multiple" filteredValue="#{viewController.selectionController.viewHelper.selectionDataManager.filteredDatas}"
	               selectionMode="single" selection="#{viewController.selectionController.viewHelper.selectionDataManager.selectedData}"  
	               resizableColumns="true" draggableColumns="true" 	                
	               scrollable="true" scrollHeight="200" > 
		   		   
		         <f:facet name="header">  		         			
		         
		         	<h:panelGrid columns="3"  columnClasses="align-l,align-c,align-r" width="100%" >
	
			             <p:outputPanel>  
			             	 <h:outputText value="Liste des donnees (#{viewController.selectionController.viewHelper.selectionDataManager.size} / #{viewController.selectionController.viewHelper.selectionDataManager.totalSize})"  />
			             </p:outputPanel>				             		        			
			         	
			             <p:outputPanel>  
			                 <p:inputText id="globalFilter" onkeyup="dataTableSelectionWV.filter()" style="width:160px;" />
			                 <p:watermark for="globalFilter" value="Rechercher dans le tableau" />  
			             </p:outputPanel>				             		        			
		
			             <p:outputPanel>  
			             	 <p:selectOneMenu value="#{viewController.selectionController.viewHelper.selectionDataManager.paginationPage}"  >
			             	 	<f:selectItems value="#{viewController.selectionController.viewHelper.selectionDataManager.paginationPageList}" />
								<f:selectItem itemLabel="101 - 200" itemValue="2" />	
								<f:selectItem itemLabel="201 - 300" itemValue="3" />	
			             	 	<p:ajax listener="#{viewController.selectionController.paginate}" update="dataTableSelection" />								             	 									             	 	
			             	 </p:selectOneMenu>
			             </p:outputPanel>				             		        			
		         			         	
		         	</h:panelGrid>
		                  			
	         	</f:facet>  
	
				<p:ajax event="rowSelect"  />
	
		         <p:column>  
			        <f:facet name="header">  
			             <h:outputText value="Id" />  
			         </f:facet>		         		             
		             <h:outputText value="#{data.id}" />   		               
		         </p:column>  
								
		         <p:column>  
			        <f:facet name="header">  
			             <h:outputText value="Libelle" />  
			         </f:facet>		         		             
		             <h:outputText value="#{data.label}" />   		               
		         </p:column>  
							  		   		         		         		   
		     </p:dataTable>	
		     
		     <p:contextMenu for="dataTableSelection">  
		         <p:menuitem value="Selectionner" action="#{viewController.selectionController.selectOnPanel}" immediate="true" process="dialogBasicSelection" update="panelViewContent" icon="ui-icon-newwin" >
		         	<f:setPropertyActionListener value="#{data}" target="#{viewController.selectionController.viewHelper.selectionDataManager.selectedData}" />  
		         </p:menuitem>  
		     </p:contextMenu>
		     						
		</p:dialog>
	
	</ui:define>					
	

</ui:composition>
